package javafx.util;

import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.effect.DropShadow;
import javafx.scene.input.MouseEvent;

public class FXButtonUtils {

	public static void shadow(Button imageButton) {
		DropShadow shadow = new DropShadow();
		// Adding the shadow when the mouse cursor is on
		imageButton.addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() {
			@Override
			public void handle(MouseEvent e) {
				imageButton.setEffect(shadow);
			}
		});
		// Removing the shadow when the mouse cursor is off
		imageButton.addEventHandler(MouseEvent.MOUSE_EXITED, new EventHandler<MouseEvent>() {
			@Override
			public void handle(MouseEvent e) {
				imageButton.setEffect(null);
			}
		});
	}

}
